package com.example.redismanual.dao;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;


@Service
public class RedisStringDao {

     @Autowired
     StringRedisTemplate stringRedisTemplate;


     //set 为字符串设置字符串呢值
     public void setStringValue(String key, String value){
         stringRedisTemplate.opsForValue().set(key, value);
     }
    
      //set 为字符串设置字符串呢值
      public void setMultiStringValue(Map<String,String> keyValueMaps){
        stringRedisTemplate.opsForValue().multiSet(keyValueMaps);
    }

     //set 为字符串设置字符串呢值
     public void setStringValueNX(String key, String value){
        stringRedisTemplate.opsForValue().setIfAbsent(key, value);
    }

     //set 为字符串设置字符串呢值
     public void setStringValueXX(String key, String value){
        stringRedisTemplate.opsForValue().setIfPresent(key, value);
    }
}
